clear;
close all;
clc;
date = datestr(datetime, 'yymmdd'); 
load joint.mat;
% load joint_speed.mat;

X=['JOINT',num2str(date),'.dat'];
diary (X);
disp('&ACCESS RVP')
disp('&REL 32')
disp('&PARAM EDITMASK = *')
disp('&PARAM TEMPLATE = C:\KRC\Roboter\Template\vorgabe')
disp('&PARAM DISKPATH = KRC:\R1\Program\liudong')

X=['DEFDAT JOINT',num2str(date)];
disp(X)%文件名
disp(';FOLD EXTERNAL DECLARATIONS;%{PE}%MKUKATPBASIS,%CEXT,%VCOMMON,%P')
disp(';FOLD BASISTECH EXT;%{PE}%MKUKATPBASIS,%CEXT,%VEXT,%P')
disp('EXT  BAS (BAS_COMMAND  :IN,REAL  :IN )')
disp('DECL INT SUCCESS')
disp(';ENDFOLD (BASISTECH EXT)')
disp(';FOLD USER EXT;%{E}%MKUKATPUSER,%CEXT,%VEXT,%P')
disp(';Make your modifications here')
fprintf('\n');
disp(';ENDFOLD (USER EXT)')
disp(';ENDFOLD (EXTERNAL DECLARATIONS)')
disp(['DECL BASIS_SUGG_T LAST_BASIS={POINT1[] "p' num2str(length(joint)) '",POINT2[] "' num2str(length(joint)) '",CP_PARAMS[] "CPDAT0",PTP_PARAMS[] "PDAT' num2str(length(joint)) '",CONT[] "C_DIS",CP_VEL[] "2.0",PTP_VEL[] "100",SYNC_PARAMS[] "SYNCDAT",SPL_NAME[] "S0",A_PARAMS[] "ADAT0"}']);
% disp(['DECL E6POS Xp1={X ' num2str(Pos(1,1)) ', Y ' num2str(Pos(1,2))  ', Z ' num2str(Pos(1,3)) ', A ' num2str(Pos(1,4)) ', B ' num2str(Pos(1,5)) ', C ' num2str(Pos(1,6)) ', S 2,T 35,E1 0.000366220,E2 360.000275,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
% disp('DECL FDAT Fp1={TOOL_NO 1,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " "}')
% disp('DECL PDAT PPDAT01={VEL 100.000,ACC 100.000,APO_DIST 500.000,APO_MODE #CDIS,GEAR_JERK 100.000,EXAX_IGN 0}')
% disp('DECL MODULEPARAM_T LAST_TP_PARAMS={PARAMS[] "Kuka.VelocityFieldEnabled=False; Kuka.ColDetectFieldEnabled=False; Kuka.MovementParameterFieldEnabled=False; Kuka.IsAngleEnabled=False; Kuka.PointName=p9; Kuka.FrameData.base_no=0; Kuka.FrameData.tool_no=1; Kuka.FrameData.ipo_frame=#BASE; Kuka.FrameData.point2=; Kuka.isglobalpoint=False; Kuka.MoveDataPtpName=PDAT09; Kuka.MovementDataPdat.apo_mode=#CDIS; Kuka.MovementDataPdat.apo_dist=500; Kuka.MovementData.vel=100; Kuka.MovementData.acc=100; Kuka.MovementData.exax_ign=0; Kuka.VelocityPtp=100; Kuka.BlendingEnabled=True; Kuka.APXEnabled=False; Kuka.CurrentCDSetIndex=0"}')
% for i=2:9
%     disp(['DECL E6POS Xp' num2str(i) '={X ' num2str(Pos(i,1)) ', Y ' num2str(Pos(i,2))  ', Z ' num2str(Pos(i,3)) ', A ' num2str(Pos(i,4)) ', B ' num2str(Pos(i,5)) ', C ' num2str(Pos(i,6)) ', S 2,T 35,E1 0.000366220,E2 360.000275,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
%     disp(['DECL FDAT Fp' num2str(i) '={TOOL_NO 1,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " "}'])
%     disp(['DECL PDAT PPDAT0' num2str(i) '={VEL 100.000,ACC 100.000,APO_DIST 500.000,APO_MODE #CDIS,GEAR_JERK 100.000,EXAX_IGN 0}'])
% end
i=1;
% disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint(i,1)) ',A2 ' num2str(joint(i,2)) ',A3 ' num2str(joint(i,3)) ',A4 ' num2str(joint(i,4)) ',A5 ' num2str(joint(i,5)) ',A6 ' num2str(joint(i,6)) ',E1 ' num2str(joint(i,7)) ',E2 ' num2str(joint(i,8)) ',E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint(i,1)) ',A2 ' num2str(joint(i,2)) ',A3 ' num2str(joint(i,3)) ',A4 ' num2str(joint(i,4)) ',A5 ' num2str(joint(i,5)) ',A6 ' num2str(joint(i,6)) ',E1 ' num2str(joint(i,7)) ',E2 ' num2str(joint(i,8)) ' ,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
% disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint1(i,1)) ',A2 ' num2str(joint1(i,2)) ',A3 ' num2str(joint1(i,3)) ',A4 ' num2str(joint1(i,4)) ',A5 ' num2str(joint1(i,5)) ',A6 ' num2str(joint1(i,6)) ',E1 ' num2str(joint1(i,7)) ',E2 ' num2str(joint1(i,8)) ' ,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
% disp(['DECL FDAT FP' num2str(i) '={TOOL_NO 1,BASE_NO 1,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}'])
disp(['DECL FDAT FP' num2str(i) '={TOOL_NO 2,BASE_NO 1,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}'])
disp(['DECL PDAT PPDAT' num2str(i) '={VEL 30.000,ACC 5.000,APO_DIST 30.000,APO_MODE #CDIS,GEAR_JERK 30.0000,EXAX_IGN 0}'])
i=2;
% disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint(i,1)) ',A2 ' num2str(joint(i,2)) ',A3 ' num2str(joint(i,3)) ',A4 ' num2str(joint(i,4)) ',A5 ' num2str(joint(i,5)) ',A6 ' num2str(joint(i,6)) ',E1 ' num2str(joint(i,7)) ',E2 ' num2str(joint(i,8)) ',E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint(i,1)) ',A2 ' num2str(joint(i,2)) ',A3 ' num2str(joint(i,3)) ',A4 ' num2str(joint(i,4)) ',A5 ' num2str(joint(i,5)) ',A6 ' num2str(joint(i,6)) ',E1 ' num2str(joint(i,7)) ',E2 ' num2str(joint(i,8)) ' ,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
% disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint1(i,1)) ',A2 ' num2str(joint1(i,2)) ',A3 ' num2str(joint1(i,3)) ',A4 ' num2str(joint1(i,4)) ',A5 ' num2str(joint1(i,5)) ',A6 ' num2str(joint1(i,6)) ',E1 ' num2str(joint1(i,7)) ',E2 ' num2str(joint1(i,8)) ' ,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
% disp(['DECL FDAT FP' num2str(i) '={TOOL_NO 1,BASE_NO 1,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}'])
disp(['DECL FDAT FP' num2str(i) '={TOOL_NO 2,BASE_NO 1,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}'])
disp(['DECL PDAT PPDAT' num2str(i) '={VEL 30.000,ACC 30.000,APO_DIST 30.000,APO_MODE #CDIS,GEAR_JERK 30.0000,EXAX_IGN 0}'])
for i=3:length(joint)
% disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint(i,1)) ',A2 ' num2str(joint(i,2)) ',A3 ' num2str(joint(i,3)) ',A4 ' num2str(joint(i,4)) ',A5 ' num2str(joint(i,5)) ',A6 ' num2str(joint(i,6)) ',E1 ' num2str(joint(i,7)) ',E2 ' num2str(joint(i,8)) ',E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint(i,1)) ',A2 ' num2str(joint(i,2)) ',A3 ' num2str(joint(i,3)) ',A4 ' num2str(joint(i,4)) ',A5 ' num2str(joint(i,5)) ',A6 ' num2str(joint(i,6)) ',E1 ' num2str(joint(i,7)) ',E2 ' num2str(joint(i,8)) ' ,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
% disp(['DECL E6AXIS XP' num2str(i) '={A1 ' num2str(joint1(i,1)) ',A2 ' num2str(joint1(i,2)) ',A3 ' num2str(joint1(i,3)) ',A4 ' num2str(joint1(i,4)) ',A5 ' num2str(joint1(i,5)) ',A6 ' num2str(joint1(i,6)) ',E1 ' num2str(joint1(i,7)) ',E2 ' num2str(joint1(i,8)) ' ,E3 0.0,E4 0.0,E5 0.0,E6 0.0}'])
% disp(['DECL FDAT FP' num2str(i) '={TOOL_NO 1,BASE_NO 1,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}'])
disp(['DECL FDAT FP' num2str(i) '={TOOL_NO 2,BASE_NO 1,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}'])
disp(['DECL PDAT PPDAT' num2str(i) '={VEL 100.000,ACC 100.000,APO_DIST 30.000,APO_MODE #CDIS,GEAR_JERK 30.0000,EXAX_IGN 0}'])
end
disp('ENDDAT')
diary off;

